#!/usr/bin/env python
#coding:utf-8

import urllib2
import urllib
import os
import imglister

imagepath = []

def cd(ss):
    try:
        os.chdir(ss)
        print '改变工作目录为:'+ss
        return 0
    except:
        print '输入图片保存路径有误，请重新输入'
        return 1

def addimagepath(surl):
    if 'http://' in surl:
        imagepath.append(surl)
        print '找到图片：'+surl.split('/')[-1]+'图片地址为：'+surl
    else:
        surl = str_url+surl
        imagepath.append(surl)
        print '找到图片：'+surl.split('/')[-1]+'图片地址为：'+surl

def imageDown(list_image):
    if not list_image:
        print '该页面没有任何图片'
    else:
        for image in list_image:
            try:
                urllib.urlretrivev(image, image.splib('/')[-1])
                print '来自'+image+'的图片保存成功！'
            except:
                print '来自%s的图片保存不成功，继续保存下一张...'%image
                
    
